# include <bits/stdc++.h>
# define MAXN 500550
using namespace std;

inline int gn() {
    int k = 0, f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
    for (; isdigit(c); c = getchar()) k = k * 10 + c - '0';
    return k * f;
}

struct seg {
    int i, l, r, p;
    long long sum;
    bool operator < (const seg &a) const {
        return sum < a.sum;
    }
};

long long sum[MAXN], ans;
int f[MAXN][22], n, k, L, R;

inline void init() {
    for(int i = 1; i <= n; i++) f[i][0] = i;
    for(int k = 1; k <= 19; k++) {
        for(int i = 1; i <= n; i++) {
            if(i + (1 << k) > n + 1) break;
            else f[i][k] = sum[f[i][k - 1]] > sum[f[i + (1 << (k - 1))][k - 1]] ? f[i][k - 1] : f[i + (1 << (k - 1))][k - 1];
        }
    }

}

inline int ask(int l, int r) {
    int k = log2(r - l + 1);
    return sum[f[l][k]] > sum[f[r - (1 << k) + 1][k]] ? f[l][k] : f[r - (1 << k) + 1][k];
}

priority_queue <seg, vector <seg> > q;

int main() {
    freopen("piano.in", "r", stdin);
    freopen("piano.out", "w", stdout);
    n = gn();
    k = gn(), L = gn(), R = gn();
    for(int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + gn();
    }
    init();
    for(int i = 1; i <= n - L + 1; i++) {
        int l = i + L - 1, r = min(n, i + R - 1);
        int p = ask(l, r);
        q.push((seg) {i, l, r, p, sum[p] - sum[i - 1]});
    }
    while(k--) {
        seg x = q.top();
        q.pop();
        ans += x.sum;
        if(x.l < x.p) {
            int w = ask(x.l, x.p - 1);
            q.push((seg) {x.i, x.l, x.p - 1, w, sum[w] - sum[x.i - 1]});
        }
        if(x.p < x.r) {
            int w = ask(x.p + 1, x.r);
            q.push((seg) {x.i, x.p + 1, x.r, w, sum[w] - sum[x.i - 1]});
        }
    }
    printf("%lld", ans);
}